package com.chujian.system.sys.controller;


import com.chujian.framework.core.base.BaseController;
import com.chujian.framework.core.base.BaseService;
import com.chujian.framework.core.tsdata.Result;
import com.chujian.sys.entity.SysDept;
import com.chujian.system.sys.service.SysDeptService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;


/**
 * 部门表控制层
 *
 * @author chujian
 * @since 2021-07-28
 */
@RequestMapping("/sysDept")
@RestController
@Slf4j
public class SysDeptController extends BaseController<SysDept> {

    @Resource
    private SysDeptService baseService;

    @Override
    public BaseService<SysDept> getBaseService() {
        return baseService;
    }

    /**
     * 树结构返回部门
     * @param deptName
     * @return
     */
    @GetMapping("/getTreeDepts")
    public Result<?> getTreeDepts(
            @RequestParam(value = "deptName", required = false) String deptName) {
        List<SysDept>  dept = baseService.getTreeDepts(deptName);
        return okRs(dept);
    }



}
